<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>vue的异步请求</title>
    <script src="js/vue.js"></script>
    <script src="js/axios-0.18.0.js"></script>
</head>
<body>
    <div id="div">
        <input type="button" value="发送get请求方式1" @click="doGet1()">
        <input type="button" value="发送get请求方式2" @click="doGet2()">
        <input type="button" value="发送post请求方式1" @click="doPost1()">
        <input type="button" value="发送post请求方式2" @click="doPost2()">
    </div>
    <script>
        new Vue({
            el:"#div",
            data:{
                user:{
                    username:"rose",
                    password:123
                }
            },
            methods:{
                // <input type="button" value="发送get请求方式1" @click="doGet1()">
                doGet1(){
                   axios.get("./ajaxServlet?username=snake&password=123456").then((resp)=>{
                       console.log(resp);
                       console.log((resp.data));
                   }).catch(e=>{});
                },
                // <input type="button" value="发送get请求方式2" @click="doGet2()">
                doGet2(){
                    axios.get("./ajaxServlet",{params:this.user}).then((resp)=>{
                        console.log(resp);
                        console.log((resp.data));
                    }).catch(e=>{});
                },
                // <input type="button" value="发送post请求方式1" @click="doPost1()">
                doPost1(){

                },
                // <input type="button" value="发送post请求方式2" @click="doPost2()">
                doPost2(){

                }
            }
        });
    </script>
</body>
</html>